package com.jiker;

import com.jiker.order.Order;

import java.util.List;

/**
 * @author leo
 * @date 2021/6/16
 */
public class MarsRover {
    private Coordinates coordinates;

    public void setCoordinates(Coordinates coordinates) {
        this.coordinates = coordinates;
    }

    public Coordinates getCoordinates() {
        return coordinates;
    }

    public Coordinates run(List<Order> orders){
        orders.forEach(order -> {
            coordinates = order.move(coordinates);
        });
        return coordinates;
    }

    public Coordinates run(List<Order> orders,List<Barrier> barriers){
        orders.forEach(order -> {
            Coordinates movedCoordinates = order.move(coordinates);
            movedCoordinates.isBarrier(barriers);
            coordinates = movedCoordinates;
        });
        return coordinates;
    }
}
